/**
 * @file src/datatypes/Point3D.java
 */
package datatypes;

/** imports */
import java.util.Vector;

/**
 * Simple point structure
 */
public class Point3D implements Comparable<Point3D> 
{
	/** location x on map */
	private final int mX;
	
	/** location y on map */
	private final int mY;
	
	/** height value */
	private final float mZ;
	
	/** neighbors of this point */
	private Vector<Point3D> mNeighbors;
	
	/**
	 * default constructor
	 * 
	 * @param x X value
	 * @param y Y value
	 * @param z Z value
	 */
	public Point3D(int x, int y, float z)
	{
		mX = x;
		mY = y;
		mZ = z;
		mNeighbors = new Vector<Point3D>();
	}
	
	/** Getter */
	public int getX() 				  { return mX; }
	public int getY() 				  { return mY; }
	public float getZ() 				  { return mZ; }
	public Vector<Point3D> getNeighbors() { return mNeighbors; }
	
	/**
	 * Test if a point has a specific neighbor
	 * 
	 * @param p Neighbor to test for
	 * 
	 * @return true or false
	 */
	public boolean hasNeighbor(Point3D p) { return mNeighbors.contains(p); }
	
	/**
	 * Add a neighbor to this point
	 * 
	 * @param p Neighbor to add
	 */
	public void addNeighbor(Point3D p)
	{
		mNeighbors.addElement(p);
	}
	
	/**
	 * Add a vector of neighbors to this point
	 * 
	 * @param p Vector of neighbors
	 */
	public void addNeighbors(Vector<Point3D> p)
	{
		mNeighbors.addAll(p);
	}
	
	/**
	 * Override toString()
	 * 
	 * @return String representation of a Point3D
	 */
	public String toString()
	{
		return "(" + mX + ", " + mY + ", " + mZ + ")";
	}

	/**
	 *  Override compareTo() to compare a Point3D's z value
	 *  
	 *  @param Point to compare to
	 *  
	 *  @return -1, 0 or 1 depending on comparison
	 */
	@Override
	public int compareTo(Point3D other)
	{
		if (mZ < other.mZ) { return -1; }
		else if (mZ > other.mZ) { return 1; }
		else { return 0; }

	} // compareTo(Point3D other)
	
} // class Point3D
